<?php

/**
 * counters actions.
 *
 * @package    erp-crm
 * @subpackage counters
 * @author     Milwell H. Sia
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class countersActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    $this->listCounterss = ListCountersPeer::doSelect(new Criteria());
    $this->listCountersForm = new ListCountersForm();
  }
  
  public function executeInsert(sfWebRequest $request){
    $list_counters = $request->getParameter('list_counters');
    $list_counters['iden'] = myStringGenerator::getIden();
    $this->listCounterss = ListCountersPeer::doSelect(new Criteria());
    $this->listCountersForm = new ListCountersForm();
    $this->listCountersForm->bind($list_counters);
    if($this->listCountersForm->isValid()){
      $this->listCountersForm->save();
      $this->redirect('counters/index');
    }
    $this->setTemplate('index');
  }
  
  public function executeEdit(sfWebRequest $request){
    $listCounters = ListCountersPeer::retrieveByPk($request->getParameter('iden'));
    $this->forward404Unless($listCounters);
    $this->listCounterss = ListCountersPeer::doSelect(new Criteria());
    $this->listCountersForm = new ListCountersForm($listCounters);
    $this->setTemplate('index');
  }
  
  public function executeUpdate(sfWebRequest $request){
    $list_counters = $request->getParameter('list_counters');
    $listCounters = ListCountersPeer::retrieveByPk($list_counters['iden']);
    $this->forward404Unless($listCounters);
    $this->listCounterss = ListCountersPeer::doSelect(new Criteria());
    $this->listCountersForm = new ListCountersForm($listCounters);
    $this->listCountersForm->bind($request->getParameter('list_counters'));
    if($this->listCountersForm->isValid()){
      $this->listCountersForm->save();
      $this->redirect('counters/index');
    }
    $this->setTemplate('index');
  }
  
  public function executeDelete(sfWebRequest $request){
    $listCounters = ListCountersPeer::retrieveByPk($request->getParameter('iden'));
    $this->forward404Unless($listCounters);
    $listCounters->delete();
    $this->redirect('counters/index');
  }

}
